﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Configuration.ServerApi.Param;
using Configuration.ServerApi.Service;
using System.Threading.Tasks;

namespace Configuration.ServerApi.Controllers
{
    /// <summary>
    /// 大模型相关Controller
    /// </summary>
    [Authorize("AuthJwt")]
    [Route("api/[controller]")]
    [ApiController]
    public class BigModelController : ControllerBase
    {
        private readonly IHostEnvironment HostEnvironment;
        private readonly IBigModelService BigModelService;

        #region 构造函数

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="hostEnvironment"></param>
        /// <param name="bigModelService"></param>
        public BigModelController(IHostEnvironment hostEnvironment,
            IBigModelService bigModelService)
        {
            HostEnvironment = hostEnvironment;
            BigModelService = bigModelService;
        }

        #endregion

        #region 获取百度API服务的Token

        /// <summary>
        /// 获取百度API服务的Token
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("BaiduAccessToken")]
        public async Task<IActionResult> BaiduAccessToken()
        {
            return await BigModelService.BaiduAccessToken();
        }

        #endregion

        #region 百度语音转文字

        /// <summary>
        /// 百度语音转文字
        /// </summary>
        /// <param name="param">搜索条件</param>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("BaiduSpeechToText")]
        public async Task<IActionResult> BaiduSpeechToText(SearchModel param)
        {
            return await BigModelService.BaiduSpeechToText(param);
        }

        #endregion

    }
}
